package org.budo.validation.exception;

import javax.validation.constraints.Max;

/**
 * @author lmw
 */
public class BudoMaxValidationException extends AbstractBudoValidationException {
    private static final long serialVersionUID = 4969260450165845737L;

    private static final String MESSAGE_DEFAULT = "{javax.validation.constraints.Max.message}";

    public BudoMaxValidationException() {}

    public BudoMaxValidationException(Integer parameterIndex, String parameterName, Max annotation, Double parameterValue) {
        super(parameterIndex, parameterName, annotation, parameterValue, validationMessage(annotation.message(), MESSAGE_DEFAULT));
    }

    @Override
    protected String buildMessage() {
        Max max = (Max) this.getAnnotation();
        return "parameter[" + this.getParameterIndex() + "] " + this.getParameterName() + " value " + this.getParameterValue() //
                + " is greater than " + max.value();
    }
}